Skip to content

[aw-compat] Migrate max-effective-tokens: -1 to max-ai-credits: -1 in codemod#38850

Merged
pelikhan merged 2 commits into
mainfrom
copilot/aw-compat-cross-repo-compilation-audit
Jun 12, 2026
Merged

[aw-compat] Migrate max-effective-tokens: -1 to max-ai-credits: -1 in codemod#38850
pelikhan merged 2 commits into
mainfrom
copilot/aw-compat-cross-repo-compilation-audit

Conversation

Copilot AI commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Cross-repo compile audits identified one persistent default-mode failure: workflows using max-effective-tokens: -1 were not migrated by gh aw fix --write, leaving an unknown legacy property behind. Positive values were already migrated; only the -1 sentinel path was skipped.

  • Codemod behavior correction

    • Updated effective-tokens-to-ai-credits migration logic to treat run-level max-effective-tokens with the same -1 sentinel semantics already used for max-daily-effective-tokens.
    • This closes the asymmetry that caused legacy max-effective-tokens: -1 to remain unmigrated.
  • Regression coverage

    • Added a focused unit test for run-level sentinel migration to ensure:
      • max-effective-tokens: -1 rewrites to max-ai-credits: -1
      • legacy key removal is preserved after rewrite.
if raw, exists := frontmatter["max-effective-tokens"]; exists {
    if normalized, ok := normalizeLegacyBudgetValue(raw, true); ok {
        maxAICreditsNormalized = normalized
        migrateMaxAICredits = true
    }
}

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix codemod gap in cross-repo compilation audit [aw-compat] Migrate max-effective-tokens: -1 to max-ai-credits: -1 in codemod Jun 12, 2026
Copilot AI requested a review from pelikhan June 12, 2026 15:30
@pelikhan pelikhan marked this pull request as ready for review June 12, 2026 15:49
Copilot AI review requested due to automatic review settings June 12, 2026 15:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes an inconsistency in the effective-tokens-to-ai-credits codemod so that the run-level sentinel value max-effective-tokens: -1 is migrated to max-ai-credits: -1, matching the existing sentinel handling for max-daily-effective-tokens. It also adds a regression test to prevent this legacy key from being left behind by gh aw fix --write.

Changes:

  • Treat max-effective-tokens: -1 as a migratable sentinel by allowing -1 in the run-level normalization path.
  • Add a focused unit test verifying the run-level -1 sentinel is rewritten to max-ai-credits: -1 and the legacy key is removed.
Show a summary per file
File Description
pkg/cli/codemod_effective_tokens_to_ai_credits.go Enables -1 sentinel migration for run-level max-effective-tokens by allowing negative-one normalization.
pkg/cli/codemod_effective_tokens_to_ai_credits_test.go Adds regression coverage for run-level max-effective-tokens: -1 migration and legacy key removal.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #38850 does not have the 'implementation' label and has only 19 new lines of code in business logic directories (≤100 threshold).

@github-actions

github-actions Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel completed test quality analysis.

@github-actions github-actions Bot mentioned this pull request Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

Test Quality Score: 90/100 — Excellent

Analyzed 1 test: 1 design (behavioral contract), 0 implementation, 0 guideline violations. Test inflation detected due to a minimal production-code change (one boolean flag) versus a full scenario test.

📊 Metrics & Test Classification (1 test analyzed)
Metric Value
New/modified tests analyzed 1
✅ Design tests (behavioral contracts) 1 (100%)
⚠️ Implementation tests (low value) 0 (0%)
Tests with error/edge cases 1 (100%)
Duplicate test clusters 0
Test inflation detected ⚠️ YES (18:1 ratio)
🚨 Coding-guideline violations 0

Test Classification Details

Test File Classification Issues Detected
TestEffectiveTokensToAICreditsCodemod_MigratesRunNegativeOne pkg/cli/codemod_effective_tokens_to_ai_credits_test.go:145 ✅ Design Assertion messages omitted (style; consistent with existing file)

Language Support

Tests analyzed:

  • 🐹 Go (*_test.go): 1 test — unit (//go:build !integration)
⚠️ Flagged Tests — Requires Review (1 minor issue)

⚠️ TestEffectiveTokensToAICreditsCodemod_MigratesRunNegativeOne (pkg/cli/codemod_effective_tokens_to_ai_credits_test.go:145)

Classification: Design test ✅ (not a failure)
Issue: Assertions lack descriptive message arguments (assert.True(t, applied), assert.Contains(...), etc.), which makes failure output less informative. This is consistent with the entire existing test file but still worth noting.
What design invariant does this test enforce? The behavioral contract that max-effective-tokens: -1 (the "disabled" sentinel) is correctly migrated to max-ai-credits: -1 — matching the parallel behavior already tested for max-daily-effective-tokens: -1.
What would break if deleted? The regression introduced in the original codemod (passing false instead of true to normalizeLegacyBudgetValue for max-effective-tokens) would go undetected.
Suggested improvement: Add descriptive messages to assertions: e.g. assert.True(t, applied, "expected codemod to be applied for max-effective-tokens: -1") and assert.Contains(t, result, "max-ai-credits: -1 # disabled", "expected -1 sentinel to be migrated"). This is a low-priority style improvement, not a blocking issue.

Note on test inflation (18:1 ratio): The production change was a single boolean flag fix (falsetrue), so the high ratio is mechanical — the test is not inflated in terms of value. The full scenario test (real YAML input, full output assertion) is the appropriate level of coverage here.

Verdict

Check passed. 0% of new tests are implementation tests (threshold: 30%). No coding-guideline violations detected.

📖 Understanding Test Classifications

Design Tests (High Value) verify what the system does:

  • Assert on observable outputs, return values, or state changes
  • Cover error paths and boundary conditions
  • Would catch a behavioral regression if deleted
  • Remain valid even after internal refactoring

Implementation Tests (Low Value) verify how the system does it:

  • Assert on internal function calls (mocking internals)
  • Only test the happy path with typical inputs
  • Break during legitimate refactoring even when behavior is correct
  • Give false assurance: they pass even when the system is wrong

Goal: Shift toward tests that describe the system's behavioral contract — the promises it makes to its users and collaborators.

References: §27426729573

🧪 Test quality analysis by Test Quality Sentinel · 211.6 AIC · ⌖ 27.2 AIC · ⊞ 28.3K ·

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 90/100. Test quality is excellent — 0% of new tests are implementation tests (threshold: 30%). The new test TestEffectiveTokensToAICreditsCodemod_MigratesRunNegativeOne is a well-structured behavioral design test that directly validates the bug fix (migrating max-effective-tokens: -1 to max-ai-credits: -1).

@pelikhan pelikhan merged commit 729f781 into main Jun 12, 2026
79 of 90 checks passed
@pelikhan pelikhan deleted the copilot/aw-compat-cross-repo-compilation-audit branch June 12, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants